/**
 * 初始化详情对话框
 */
var BusinessClassifyInfoDlg = {
    businessClassifyInfoData : {}
};

/**
 * 清除数据
 */
BusinessClassifyInfoDlg.clearData = function() {
    this.businessClassifyInfoData = {};
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
BusinessClassifyInfoDlg.set = function(key, val) {
    this.businessClassifyInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
BusinessClassifyInfoDlg.get = function(key) {
    return $("#" + key).val();
}

/**
 * 关闭此对话框
 */
BusinessClassifyInfoDlg.close = function() {
    parent.layer.close(window.parent.BusinessClassify.layerIndex);
}

/**
 * 收集数据
 */
BusinessClassifyInfoDlg.collectData = function() {
    this
    .set('id')
    .set('title')
    .set('imageSrc')
    .set('sort');
    
	var appid = localStorage.getItem("appid");//获取存储的变量key的值 
	if(appid){
		 this.businessClassifyInfoData['appId'] = appid;
	}
}

/**
 * 提交添加
 */
BusinessClassifyInfoDlg.addSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/businessClassify/add", function(data){
        Feng.success("添加成功!");
        window.parent.BusinessClassify.table.refresh();
        BusinessClassifyInfoDlg.close();
    },function(data){
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.businessClassifyInfoData);
    ajax.start();
}

/**
 * 提交修改
 */
BusinessClassifyInfoDlg.editSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/businessClassify/update", function(data){
        Feng.success("修改成功!");
        window.parent.BusinessClassify.table.refresh();
        BusinessClassifyInfoDlg.close();
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.businessClassifyInfoData);
    ajax.start();
}

$(function() {
	 // 初始化头像上传
    var avatarUp = new $WebUpload("imageSrc");
    avatarUp.setUploadBarId("progressBar");
    avatarUp.setMultiple(true);
    avatarUp.init();
});
